/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.can.bc;

import edu.upn.sigemfi.can.be.TransaccionExternaWeb;
import edu.upn.sigemfi.can.be.TransaccionGiroWeb;
import edu.upn.sigemfi.can.be.TransaccionInternaWeb;
import edu.upn.sigemfi.can.be.TransaccionWeb;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author
 */
@Stateless
public class TransaccionWebFacade implements TransaccionWebFacadeLocal {

    @PersistenceContext
    private EntityManager em;

    public void create(TransaccionWeb transaccionWeb) {
        em.persist(transaccionWeb);
    }

    public void edit(TransaccionWeb transaccionWeb) {
        em.merge(transaccionWeb);
    }

    public void remove(TransaccionWeb transaccionWeb) {
        em.remove(em.merge(transaccionWeb));
    }

    public TransaccionWeb find(Object id) {
        return em.find(TransaccionWeb.class, id);
    }

    public List<TransaccionWeb> findAll() {
        return em.createQuery("select object(o) from TransaccionWeb as o").getResultList();
    }

    //Transaccion Giro Web
    public TransaccionGiroWeb findGiroWeb(Object id) {
        return em.find(TransaccionGiroWeb.class, id);
    }

    public List<TransaccionGiroWeb> findAllGirosWebs() {
        return em.createQuery("select object(o) from TransaccionGiroWeb as o").getResultList();
    }

    public List<TransaccionGiroWeb> findGiroWebByDestinatario(String criterio) {
        return em.createQuery("select object(o) from Transaccion Giro Web o where o.nombre_destinatario like '%" + criterio + "%'").getResultList();
    }

    //Transaccion Externa Web
    public TransaccionExternaWeb findExternaWeb(Object id) {
        return em.find(TransaccionExternaWeb.class, id);
    }

    public List<TransaccionExternaWeb> findAllExternaWebs() {
        return em.createQuery("select object(o) from TransaccionExternaWeb as o").getResultList();
    }

    //Transaccion Interna Web
    public TransaccionInternaWeb findInternaWeb(Object id) {
        return em.find(TransaccionInternaWeb.class, id);
    }

    public List<TransaccionInternaWeb> findAllInternaWebs() {
        return em.createQuery("select object(o) from TransaccionInternaWeb as o").getResultList();
    }
}
